# Python 2.6.4
# Project Euler, Problem 87
# Copyright 2010 Talha Zaman

from mine import sieveprimes
from math import sqrt
lim = 50000000
p = sieveprimes(int(sqrt(lim)))
total = [0]*lim
for i in p:
    for j in p[:74]:
        for k in p[:24]:
            combo = i**2 + j**3 + k**4
            if combo<lim: total[combo] = 1
print sum(total)
